package com.yun.common.core.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yun.common.core.base.entity.BaseEntity;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.HashSet;
import java.util.Set;

@TableName("sys_role")
public class SysRole extends BaseEntity {
    /** 角色id **/
    @TableId(type = IdType.AUTO )
    private Long roleId;
    /** 角色名 **/
    @NotBlank(message = "角色名称不能为空")
    @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
    private String roleName;
    /** 角色Key **/
    @NotBlank(message = "权限字符不能为空")
    @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
    private String roleKey;
    /** 顺序 **/
    @NotBlank(message = "显示顺序不能为空")
    private Integer roleSort;
    /** 角色状态 1正常，0停用**/
    private Boolean enable;
    /** 删除标识**/
    private Boolean delFlag;
    /** 备注 **/
    private String remark;

    private Boolean menuCheckStrictly;

    /** 菜单组 */
    @TableField(exist = false)
    private Long[] menuIds;

    @TableField(exist = false)
    private Set<SysMenu> menus = new HashSet<>();

    public SysRole() {}

    public SysRole(Long roleId)
    {
        this.roleId = roleId;
    }


    public boolean isAdmin()
    {
        return isAdmin(this.roleId);
    }

    public static boolean isAdmin(Long roleId)
    {
        return roleId != null && 1L == roleId;
    }


    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleKey() {
        return roleKey;
    }

    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }

    public Integer getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(Integer roleSort) {
        this.roleSort = roleSort;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public Boolean getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Boolean delFlag) {
        this.delFlag = delFlag;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public void setMenus(Set<SysMenu> menus) {
        this.menus = menus;
    }

    public Set<SysMenu> getMenus() {
        return menus;
    }

    public void setMenuIds(Long[] menuIds) {
        this.menuIds = menuIds;
    }

    public Long[] getMenuIds() {
        return menuIds;
    }

    public Boolean getMenuCheckStrictly() {
        return menuCheckStrictly;
    }

    public void setMenuCheckStrictly(Boolean menuCheckStrictly) {
        this.menuCheckStrictly = menuCheckStrictly;
    }
}
